    {layout name="common/layout" /}
<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>

<div class="Hui-article-box" style="margin-top: 37px;">
	<div class="breadcrumb"><i class="Hui-iconfont"></i>评价管理
	<span class="c-gray en">&gt; 
	</div>
	<div class="Hui-article">
			<div style="overflow: hidden;width: 1000px;height: 76px;border:1px solid #ccc;margin:20px auto;">
				<div style="float: left;margin-left: 30px;">
					<h3>评价管理</h3>
				</div>
			</div>
			<div class="mt-20" style="width: 1000px;margin:20px auto;">
				<div id="tab_demo" class="HuiTab cl">
				  <div class="tabBar clearfix" style="float: left;"><span>已回复</span><span>未回复</span></div>
						<div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer" style="margin-top: 7px;float:right;">
							<div class="dataTables_length" id="DataTables_Table_0_length" style="float: none;">
								<label>
									<form action="{:url('goodscomment/showlist')}" method="get" style="width: 120px;margin-left: 30px; padding: 0 0 0 0">
									显示 
									<select id="pagesize" onchange="this.parentNode.submit()" name="DataTables_Table_0_length" aria-controls="DataTables_Table_0" class="select">
									<?php $pagesize = input('param.DataTables_Table_0_length'); ?>
										<option value="10" {if($pagesize == 10)}selected="selected"{/if}>10</option>
										<option value="25" {if($pagesize == 25)}selected="selected"{/if}>25</option>
										<option value="50" {if($pagesize == 50)}selected="selected"{/if}>50</option>
										<option value="100" {if($pagesize == 100)}selected="selected"{/if}>100</option>
									</select> 
									条
						</form>
								</label>
							</div>
						</div>	
				<div class="tabCon">
					<table class="table table-border table-bg  table-bordered" style="margin-bottom: 20px;line-height: 30px;height: 30px;">
						<input type="hidden" class="r_type" value="{$type}"/>
 						<tr class="text-c first-tr">
 							<td>用户名</td>
 							<td>商品名称</td>
 							<td>评价内容</td>
 							<td>评价时间</td>
 							<td>回复内容</td>
 							<td>操作状态</td>
  						</tr>
  						{foreach($replyed as $k => $v)}
  						
  						<tr style="height: 120px;" class="text-c">
 							<td>{$v['nickname']}</td>
 							<td><span style="color: #00f;">{$v['goods_name']}</span></td>
 							<td>{$v['comment_content']}</td>
 							<td>{$v['comment_create_time']}</td>
 							<td>{$v['replay_reply']}</td>
 							<td><a href="javascript:void(0)" onclick="modaldemo({$v['comment_id']},'{$v['replay_reply']}')" style="color: #00f; cursor: pointer;">修改</a></td>
  						</tr>
  						{/foreach}
					</table>
					<div class="cl">
					{$replyed->render()}
					</div>
					<div id="modal-demo" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="">
					<div class="modal-dialog">
						<div class="modal-content radius" style="width:584px;">
							<div class="modal-header">
								<h3 class="modal-title" style="text-align: center;">商家回复</h3>
								<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
							</div>
							<div class="modal-body">
								<textarea name="updateComment" id="" cols="90" rows="15"></textarea>
							</div>
							<div class="modal-footer">
								<span id="btn_update" class="btn btn-primary"  >确定</span> 
								<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
							</div>
						</div>
					</div>
				<div class="cl">
						<div class="dataTables_info f-l" id="DataTables_Table_0_info" role="status" aria-	live="polite" style="margin-top: 15px;">显示 1 到 {$pagesize? $pagesize : 2} ，共 {$replyed->total()} 条</div>
				 		{$replyed->render()}
					</div>
				</div>
			</div>	
				<div class="tabCon">
					<table class="table table-border table-bg  table-bordered" style="margin-bottom: 20px;line-height: 30px;height: 30px;">
 						<tr class="text-c first-tr">
 							<td>用户名</td>
 							<td>商品名称</td>
 							<td>评价内容</td>
 							<td>评价时间</td>
 							<td>回复内容</td>
 							<td>操作状态</td>
  						</tr>
  						{foreach($not_reply as $k1 => $v1)}
  						<tr style="height: 120px;" class="text-c">
 							<td>{$v1['nickname']}</td>
 							<td><span style="color: #00f;">{$v1['goods_name']}</span></td>
 							<td>{$v1['comment_content']}</td>
 							<td>{$v1['comment_create_time']}</td>
 							<td>{$v1['replay_reply']}</td>
 							<td><a href="javascript:void(0)" onclick="modaldemo1({$v1['comment_id']},'{$v1['replay_reply']}')" style="color: #00f; cursor: pointer;">回复</a></td>
  						</tr>
  						{/foreach}
  						
					</table>
					<div class="cl">
						{$not_reply->render()}
					</div>
					<div id="modal-demo1" class="modal fade" tabindex="-1" role="dialog" style="" aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content radius" style="width:584px;">
							<div class="modal-header">
								<h3 class="modal-title" style="text-align: center;">商家回复</h3>
								<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
							</div>
							<div class="modal-body">
								<textarea name="comment_replay" id="comment_replay" cols="90" rows="15">
									
								</textarea>
							</div>
							<div class="modal-footer">
								<span id="btn_add"  class="btn btn-primary"  >确定</span>
								<button   class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
							</div>
						</div>
					</div>
				<div class="cl">
						<div class="dataTables_info f-l" id="DataTables_Table_0_info" role="status" aria-	live="polite" style="margin-top: 15px;">显示 1 到 {$pagesize? $pagesize : 2} ，共 {$not_reply->total()} 条</div>
				 		{$not_reply->render()}
					</div>
				</div>
			</div>
	</div>
</div>
	
 
<script>
	$(function(){
        var type = "{$type}";
		$.Huitab("#tab_demo .tabBar span","#tab_demo .tabCon","current","click",type);
	});
	/*var GG = {
        "kk":function(mm){
           var ym=mm;
        }
    }
	$("#page").initPage(71,1,GG.kk);
	$("#page1").initPage(71,1,GG.kk);
	$("#page2").initPage(71,1,GG.kk);
	$("#page3").initPage(71,1,GG.kk);
	$("#page4").initPage(71,1,GG.kk);*/

	function modaldemo(comment_id,reply_content){
		writeCookie('id',comment_id);
		writeCookie('content',reply_content);
		var content=readCookie('content');
	var val= $('#modal-demo').find('.modal-body').children().html(content);
		$("#modal-demo").modal("show");
		// alert(comment_id);
		
		
	}
	function modaldemo1(comment_id){
		writeCookie('id',comment_id);
		$("#modal-demo1").modal("show");
		var val= $('#modal-demo1').find('.modal-body').children().html();
		$("#comment_replay").val('');
	}

	function reply(comment_id)
	{
		var id=readCookie('id');
		comment_id=id;
	 
		var content = $('textarea[name=comment_replay]').val();
		 
		$.ajax({
			type:'post',
			url:"{:url('goodscomment/insert', '', false)}",
			data:{comment_id:comment_id,content:content},
			success:function(data){
				if(data.status == 1)
				{
					layer.msg(data.msg);
					$("#modal-demo").modal("hide");
					setTimeout(function(){
						location.reload();
					},1000)
				}
			}
		})
	}
	function update(comment_id,obj)
	{
		var id=readCookie('id');
		comment_id=id;
		var content = $('textarea[name=updateComment]').val();

		$.ajax({
			type:'post',
			url:"{:url('goodsreply/update', '', false)}",
			data:{comment_id:comment_id,content:content},
			success:function(data){
				if(data.status == 1)
				{
					layer.msg(data.msg);
					$("#modal-demo").modal("hide");
					setTimeout(function(){
						location.reload();
					},1000)
				}
			}
		})
	}
	function readCookie (name)
    {
        var cookieValue = "";
        var search = name + "=";
        if (document.cookie.length > 0)
        {
            offset = document.cookie.indexOf (search);
            if (offset != -1)
            {
                offset += search.length;
                end = document.cookie.indexOf (";", offset);
                if (end == -1)
                    end = document.cookie.length;
                cookieValue = unescape (document.cookie.substring (offset, end))
            }
        }
        return cookieValue;
    }
    function writeCookie (name, value, hours)
    {
        var expire = "";
        if (hours != null)
        {
            expire = new Date ((new Date ()).getTime () + hours * 3600000);
            expire = "; expires=" + expire.toGMTString ();
        }
        document.cookie = name + "=" + escape (value) + expire;
    }

     $("#btn_add").click(function(){
        reply(null);
     });
     $("#btn_update").click(function(){
        update(null);
     });

    $(".pagination").find("li").click(function () {
        var link = $(this).find("a").attr("href");
        link+="&type="+$(".r_type").val();
        $(this).find("a").attr("href",link);
    });
    function checkstatus(){
        var type = 0;
        if($("#tab_demo .tabBar").find("span.current").text() == "已回复"){
            type = 0;
        }else{
            type = 1;
        }
        $(".r_type").val(type);
        //console.log($(".r_type").val());
    }
    setInterval(checkstatus,500);
</script>
 